import EventEmitter from "../eventEmitter";

export class DrawInteractor extends EventEmitter {
  target: HTMLCanvasElement;
  constructor(target: HTMLCanvasElement) {
    super();
    this.target = target;
    this.init();
  }
  init() {
    this.handleMouseDown = this.handleMouseDown.bind(this);
    this.handleMouseUp = this.handleMouseUp.bind(this);
    this.handleMouseMove = this.handleMouseMove.bind(this);
    this.handleDoubleClick = this.handleDoubleClick.bind(this);
    this.target.addEventListener("mousedown", this.handleMouseDown);
    this.target.addEventListener("mouseup", this.handleMouseUp);
    this.target.addEventListener("mousemove", this.handleMouseMove);
    this.target.addEventListener("dblclick", this.handleDoubleClick);
  }
  destroy() {
    this.target.removeEventListener("mousedown", this.handleMouseDown);
    this.target.removeEventListener("mouseup", this.handleMouseUp);
    this.target.removeEventListener("mousemove", this.handleMouseMove);
    this.target.removeEventListener("dblclick", this.handleDoubleClick);
    this.clear();
  }
  handleMouseDown(e: MouseEvent) {}
  handleMouseUp(e: MouseEvent) {}
  handleMouseMove(e: MouseEvent) {}
  handleDoubleClick(e: MouseEvent) {}
}
